package com.example.algorithm.leetcode;

/**
 * @author yuzhenxin
 * @date 2023-02-05 21:04
 * @description Leetcode-136：只出现一次的数字
 */
public class SingleNumber {

    public static void main(String[] args) {
        System.out.println(singleNumber(new int[]{4, 2, 3, 2, 3}));
    }

    public static int singleNumber(int[] nums) {
        // a ^ a = 0
        // 0 ^ a = a
        int ans = 0;
        for (int num : nums) {
            ans ^= num;
        }
        return ans;
    }

}
